#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
using namespace std;

class complex
{
public:
	complex(double r = 0, double i = 0)
		:_real(r), _imag(i)
	{}
	double getreal()const
	{
		return _real;
	}
	double getimag()const
	{
		return _imag;
	}
	complex& operator+=(const complex& a)
	{
		_real += a._real;
		_imag += a._imag;
		return *this;
	}
	complex operator+(const complex& a)const
	{
		complex ret;
		ret._real = a._real + this->_real;
		ret._imag = a._imag + this->_imag;
		return ret;
	}


private:
	double _real;
	double _imag;
};

ostream& operator<<(ostream& cout, const complex& a)
{
	cout << a.getreal() << '+' << a.getimag() << 'i';
	return cout;
}


int main()
{
	complex c1(1, 2);
	complex c2;
	cout << c1 << endl;
	cout << c2 << endl;
	cout << (c1 + c2) << endl;
	c1 += c2;
	cout << c1 << endl;
	c2 += c1;
	cout << c2 << endl;
	return 0;
}